from models import DB



class User(DB.Model):
    # 定义表名
    __tablename__ = 'user' # 定义表名
    # 定义列对象
    id = DB.Column(DB.Integer, primary_key=True)
    name = DB.Column(DB.String(64),  nullable=False)
    email = DB.Column(DB.String(64), unique=True, nullable=False)
    password = DB.Column(DB.String(64), nullable=False)
    # 设置外键[用于1查询多的情况]
    # us = DB.relationship('User', backref='role',lazy='dynamic')

    # repr()方法类似于django的__str__，用于打印模型对象时显示的字符串信息
    def __repr__(self):
        return 'User:%s-%s'% self.name, self.email
